package com.net.shop.car.manager.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringAndDateUtils {
	/**
	 * 判断字符串是否是"null",null,""
	 * 
	 * @param str
	 * @return
	 */
	public static boolean isStrNull(String str) {
		if (null != str && !"".equals(str) && !"null".equals(str)) {
			return false;
		}
		return true;

	}

	public static String nullStrToStr(String nullStr, String toStr) {
		if (isStrNull(nullStr)) {
			return toStr;
		} else {
			return nullStr;
		}
	}

	/**
	 * 验证手机码
	 * 
	 * @param mobiles
	 * @return
	 */
	public static boolean isMobileNum(String mobiles) {
		Pattern p = Pattern
				.compile("^((1[0-9])|(1[^0,\\D])|(1[0,5-9]))\\d{9}$");
		Matcher m = p.matcher(mobiles);
		return m.matches();
	}

	/**
	 * 判断邮箱格式是否正确
	 * 
	 * @param email
	 * @return
	 */
	public static boolean isEmail(String email) {
		String str = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
		Pattern p = Pattern.compile(str);
		Matcher m = p.matcher(email);
		return m.matches();
	}

}
